package com.css.openapi.BO;

import com.css.common.core.utils.BaseUtil;
import com.css.common.core.utils.InvoiceUtil;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.math.BigDecimal;

/**
 * <p>
 * 订单通用明细表
 * </p>
 *
 * @author qinxb
 * @since 2024-09-06 02:26:11
 */
@Data
public class OrderTymxV2Vo implements Serializable {

    private static final long serialVersionUID = 1L;

    @NotNull(message = "明细序号不能为空")
    @Min(value=1,message ="明细序号不能小于1" )
    @ApiModelProperty("明细序号")
    @JsonProperty(value = "mxxh")
    private Integer mxxh;

    @NotNull(message = "税率征收率不能为空")
    @DecimalMin(value = "0.01",message = "税率征收率不能小于0.01")
    @DecimalMax(value = "1",message = "税率征收率不能大于1")
    @Digits(integer=0,fraction = 2,message = "税率征收率格式错误")
    @ApiModelProperty("税率征收率")
    @JsonProperty(value = "slzsl")
    private BigDecimal slzsl;

    @NotBlank(message = "商品和服务税收分类编码不能为空")
    @ApiModelProperty("商品和服务税收分类编码")
    @JsonProperty(value = "sphfwflbm")
    private String sphfwflbm;

    @NotBlank(message = "项目名称不能为空")
    @ApiModelProperty("项目名称")
    @JsonProperty(value = "xmmc")
    private String xmmc;

    @Positive(message = "单价必须为正数")
    @ApiModelProperty("单价")
    @JsonProperty(value = "price")
    private BigDecimal price;

    @Positive(message = "数量必须为正数")
    @ApiModelProperty("数量")
    @JsonProperty(value = "num")
    private BigDecimal num;

    @ApiModelProperty("规格型号")
    @JsonProperty(value = "ggxh")
    private String ggxh;

    @NotBlank(message = "单位不能为空")
    @ApiModelProperty("单位")
    @JsonProperty(value = "dw")
    private String dw;

    @NotNull(message = "价税合计不能为空")
    @Positive(message = "价税合计不能为负数")
    @Digits(integer=16,fraction = 2,message = "价税合计格式错误")
    @ApiModelProperty("价税合计")
    @JsonProperty(value = "taxAmount")
    private BigDecimal taxAmount;

    @ApiModelProperty("不动产权证号")
    @JsonProperty(value = "bdcqzh")
    private String bdcqzh;

    @ApiModelProperty("发票行性质（00：正常行，01：折扣行，02：被折扣行）")
    @JsonProperty(value = "fphxz")
    private String fphxz="00";

    @ApiModelProperty("优惠政策标识")
    @JsonProperty(value = "yhzcbs")
    private String yhzcbs;

    /**
     * 获取不含税金额
     * @return
     */
    public BigDecimal getBhsje(){
        if(BaseUtil.isNull(this.taxAmount)||BaseUtil.isNull(slzsl))return null;//。
        return InvoiceUtil.toJe(this.taxAmount, slzsl);
    }
}
